//
//  StayBehindSearchViewController.m
//  Utils
//
//  Created by enghou on 2018/4/27.
//  Copyright © 2018年 xyxorigation. All rights reserved.
//

#import "StayBehindSearchViewController.h"
#import "NSMutableDictionary+SetContent.h"
@interface StayBehindSearchViewController ()

@end

@implementation StayBehindSearchViewController

-(NSDictionary *)param{
    NSMutableDictionary *param = [NSMutableDictionary dictionary];
    [param setContent:self.nameField.text forKey:@"searchLeftBehindPeopleVo.name" conentNeeded:NO];
    [param setContent:self.idCardField.text forKey:@"searchLeftBehindPeopleVo.idCardNo" conentNeeded:NO];
    [param setContent:self.addressDetailField.text forKey:@"searchLeftBehindPeopleVo.currentAddress" conentNeeded:NO];
//    searchVo.logOut
    [param setContent:self.zhuxiaoModel.ids forKey:@"searchLeftBehindPeopleVo.logout" conentNeeded:NO];
    [param setContent:self.deathModel.ids forKey:@"searchLeftBehindPeopleVo.isDeath" conentNeeded:NO];
    [param setContent:self.sexModel.ids forKey:@"searchLeftBehindPeopleVo.gender.id" conentNeeded:NO];
    [param setContent:self.minzuModel.ids forKey:@"searchLeftBehindPeopleVo.nation" conentNeeded:NO];
    [param setContent:self.marryModel.ids forKey:@"searchLeftBehindPeopleVo.maritalState" conentNeeded:NO];
    [param setContent:self.politicalModel.ids forKey:@"searchLeftBehindPeopleVo.politicalBackground" conentNeeded:NO];
    [param setContent:self.eduModel.subTid forKey:@"searchLeftBehindPeopleVo.schoolStr" conentNeeded:NO];
    [param setContent:self.beginDateField.text forKey:@"searchLeftBehindPeopleVo.birthday" conentNeeded:NO];
    [param setContent:self.endDateField.text forKey:@"searchLeftBehindPeopleVo.endBirthday" conentNeeded:NO];
    
    return param;
}

- (void)viewDidLoad {
    [super viewDidLoad];
    
    // Uncomment the following line to preserve selection between presentations.
    // self.clearsSelectionOnViewWillAppear = NO;
    
    // Uncomment the following line to display an Edit button in the navigation bar for this view controller.
    // self.navigationItem.rightBarButtonItem = self.editButtonItem;
}


-(void)chooseRelation{
    if (self.relations) {
        [self alertWithArray:self.relations choosenBock:^(PropertyDictItemModel *model) {
            self.relationModel = model;
            self.relationLabel.text = self.relationModel.displayName;
        }];
    }else{
        [self commonAlertWithContent:@"与户主关系" choosenBlock:^(PropertyDictItemModel *model) {
            self.relationModel = model;
            self.relationLabel.text = self.relationModel.displayName;
        } getList:^(NSArray *array) {
            self.relations = array;
        }];
    }
}

-(void)choosePersonType{
    if (self.personTypes) {
        [self alertWithArray:self.personTypes choosenBock:^(PropertyDictItemModel *model) {
            self.personTypeModel = model;
            self.personTypeLabel.text = self.personTypeModel.displayName;
        }];
    }else{
        [self commonAlertWithContent:@"留守人员类型" choosenBlock:^(PropertyDictItemModel *model) {
            self.personTypeModel = model;
            self.personTypeLabel.text = self.personTypeModel.displayName;
        } getList:^(NSArray *array) {
            self.personTypes = array;
        }];
    }
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

#pragma mark - Table view data source
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
    if (indexPath.row < 11) {
        [super tableView:tableView didSelectRowAtIndexPath:indexPath];
    }else if (indexPath.row == 11){
        [self chooseRelation];
    }else if (indexPath.row == 12){
        [self choosePersonType];
    }
}
@end
